Using the Prompt Box Component
The Prompt Box component, included with the Macromedia Flash UI Components Set 3, provides a window with an input field, similar to a JavaScript prompt window. This is useful for retrieving input from users, when the application depends on that input to continue.
The component comes with a number of icons to display in the box, and allows you to specify additional icons.

Sample files
Before you begin this tutorial, download the source file so that you can follow along in Macromedia Flash MX:
Using the Prompt Box component
Using the Prompt Box component only requires that it be inserted into the Macromedia Flash application from the components panel. The component's default state is on, and inserting it and testing the movie, will result in a Prompt Box window displaying the default information and settings.
In order to retrieve the user’s input, you can call the getUserInput method:
var input = myPromptBox.getUserInput();
trace("User input : " + input);
This will normally be called once the user has pressed a button on the prompt box indicating that they have submitted the content.
The value is also passed to the Close Handler:
closehandler = function(promptBox, buttonIndex, userInputValue)
{
//get the label of the button that was pressed
var buttonLabel = promptBox.getButtons()[buttonIndex];
//figure out which button was pressed
switch(buttonLabel.toLowerCase())
{
case "cancel":
return;
case "ok":
//if it was "ok" then copy the users input
//to the text field.
outputField.text = "Hello " + userInputValue +
"!";
break;
}
}
Which, if defined, is called when the user presses a button on the Prompt Box component.
Customizing and controlling the Prompt Box component
There are a number of ways to control and customize the component.
The first step involves using the Property inspector to specify the initial settings for the component. Here is a list of properties available and a short description:
- Title: The title to be displayed on the Prompt Box.
- Message: The message to be displayed within the Prompt Box.
- Answer: The default text to be displayed within the text field.
- Icon: The icon to be displayed within the Prompt Box. The default options are none, fpb_warningIcon (a warning symbol icon), fpb_errorIcon (an error symbol icon), fpb_questionIcon (a question mark icon) and fpb_infoIcon (and info symbol icon).
- Buttons: An array of strings containing the labels of desired buttons. A button will be created for each item within the array.
- Close Handler: A reference to the function to be called when one of the buttons is clicked.
- Button Width: Defines the width of the buttons.
- Titlebar Height: Defines the height of the title bar.
- ActiveState: Denotes if the Loading Box is active, useable and visible when the SWF file starts.
You can also interact with and customize the Prompt Box at runtime, by using the Prompt Box’s ActionScript API.
You can view a complete list of the API, as well as descriptions and examples, in the Macromedia Flash MX Reference Panel (Window > Reference Panel) under the Flash UI Components Set 3 section.
Finally, the component can be customized through the use of FStyleFormat properties. The following properties are supported:
- FStyleFormat.face
- FStyleFormat.highlight
- FStyleFormat.shadow
- FStyleFormat.darkshadow
- FStyleFormat.highlight3D
- FStyleFormat.textAlign
- FStyleFormat.textBold
- FStyleFormat.textColor
- FStyleFormat.textDisabled
- FStyleFormat.textFont
- FStyleFormat.textIndent
- FStyleFormat.textItalic
- FStyleFormat.textLeftMargin
- FStyleFormat.textRightMargin
- FStyleFormat.textSize
- FStyleFormat.textUnderline
The following is a list of the supported style properties (for the input text field):
- backgroundColor
- maxChars
- password
- restrict
- bold
- font
- italic
- size
- color
Here is a code example that illustrates the way these properties are set:
myPromptBox.setInputProperty("backgroundColor", 0xFF0099);